package fr.mywiki.src.view;

import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

import fr.mywiki.business.entry.EntryLite;
import fr.mywiki.model.ejbAdapter.EntityHomeCache;
import fr.mywiki.model.ejbAdapter.ServicesFacade;

/**
 * @web.servlet name = "HelloWorldServlet"
 * 
 * @web.servlet-mapping url-pattern = "/Howdy"
 */
public class HelloWorldServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void service(ServletRequest req, ServletResponse response)
			throws ServletException {
		PrintWriter out = null;

		try {
			response.setContentType("text/html");

			out = response.getWriter();

			ServicesFacade.getInstance().create(EntryLite.TYPE_ENT);
			EntityHomeCache.getInstance().getEntryHome().create(new Long(1));

			out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "
					+ "Transitional//EN\">\n" + "<HTML>\n"
					+ "<HEAD><TITLE>XDocletDemo</TITLE></HEAD>\n" + "<BODY>\n");

			String little = "hello world!!";

			out.println("<H1>Before: " + little + "</H1>\n");
		} catch (Exception e) {
			e.printStackTrace(out);
			throw new ServletException(e);
		} finally {
			out.println("<BODY></HTML>");
		}
	}
}